<?php
/**
 * Created by PhpStorm.
 * User: LG
 * Date: 2018/9/11
 * Time: 17:21
 */

header("content-type:text/html;charset=utf-8");         //设置编码
require_once 'Medoo.php';
require_once 'Contact.php';

/**
 * 获取媒体开关状态类 GET
 * 前端入参：
 *  modularID:  模块开关ID
 */
$modularID = $_GET['modularID'];

selectState($modularID);





/**
 * @return 判断是否有该条记录
 */
function hasRecoved()
{
    global $database;
    global $modularID;
    if ($database->has("manage_media_switch", array("modularid" => $modularID))) {
        return true;
    } else {
        return false;
    }
}


/**
 * 查询该ID的开关状态
 */
function selectState($modularID)
{
    global $database;
    global $modularID;


if(!hasRecoved()){
    $result1 = array(
        'code' => urlencode(200),
        'msg' => urlencode('无数据'),
        'data' => null
    );
    echo urldecode(json_encode($result1));
}


    $result = null;
    // 查询数据示例
    $datas = $database->select("manage_media_switch", [
        "modularid",
        "media_service",
        "media_ui",
        "media_vioce",
        "media_cancat",
        "media_all_finaldevice",
        "media_all_mediadevice"

    ], [
        "modularid[=]" => $modularID
    ]);

    foreach ($datas as $data) {
        $result0 = array(
            'modularid' => urlencode($data["modularid"]),
            'media_service' => urlencode($data["media_service"]),
            'media_ui' => urlencode($data["media_ui"]),
            'media_vioce' => urlencode($data["media_vioce"]),
            'media_cancat' => urlencode($data["media_cancat"]),
            'media_all_finaldevice' => urlencode($data["media_all_finaldevice"]),
            'media_all_mediadevice' => urlencode($data["media_all_mediadevice"]),

        );

        $result1 = array(
            'code' => urlencode(200),
            'msg' => urlencode('查询成功'),
            'data' => $result0
        );
        echo urldecode(json_encode($result1));
    }
}




